HOMEWORK 2. Run any example in WinBUGS from the Help menu and then run diagnostics in R. We will go over this WED in class in more detail in case you are lost right now! Run model in WinBUGS --open the model specification window in the model menu --highlight the word 'model' and click check model --highlight the word 'list' for the data and click load data --set number of chains (usually 2 is sufficient) --highlight the word 'list' for the initial values and click the load inits (for all chains) --click the gen inits button if there are still uninitialized variables in the model. --you will receive the message 'model is initialized' if you've done everything correctly. --open the samples window from the inference menu --set the nodes you want to monitor by typing them in the 'node' box and clicking set after each one --enter an * in the node box --open the update window from the Model menu --set number of updates (several thousand) and click the update button. --go back to the sample monitor menu and click the trace button to watch the chains (hopefully watching them head toward convergence) --continue updating model until you think the chains are exploring the same space--hopefully this is the posterior distribution!! --set the beg value to some number--usually 1000--to get rid of the first 1000 iterations of the chain(s). This is the 'burn-in period'. --check things like densitys, autocorrelations to make a first assessment of convergence. --click on the 'coda' button to get the chains and the index files to import into R --save each chain directly from the winBUGS window--BEING SURE TO SAVE THEM AS FILE TYPE: .TXT!!!!!!! --save the index file to the c:\temp folder. BE SURE TO SAVE THE FILE USING THE FOLLOWING PROCEDURE: call it whatever you want--I'll call the files chain1 and chain2 save the file as "chain.1.out" and "chain.2.out" BE SURE TO USE THE " " AROUND THE FILE NAME AND TO SAVE THEM AS FILE TYPE .TXT. Do not add the .txt extension!! save the index file as: "chain.ind" --also as file type .txt. --open R --type library(boa) --type boa.menu() --from BOA main menu, choose option 1: File --from FILE MENU, choose option 3: Import Data --from IMPORT DAta MENU, choose option 7: Options... --from Import Parameters Menu, choose option 1: working Directory --enter c:/temp (notice the forward slash!!!!) --from IMPORT DATA MENU, choose option 3: CODA Output files --enter the name of the index file WITHOUT an extension using my example above type: chain --enter the name of the .out file WITHOUT an extension using my example above type: chain.1 --Now repeat the process to read in the second chain. Do exactly as you did before, but use the .out file chain.2 (you can use the same .ind file). --from the IMPORT DATA MENU, choose option 1: Back --from the FILE MENU, choose option 1: Back --from the BOA MAIN MENU, choose Analysis or Plot and have fun!!